package com.school;

public class Test_2 {
    public static void main(String[] args) {
        Vehicle vehicle = new Vehicle(8,2000);
        Car car = new Car(4,1500,4);
        vehicle=car;
        vehicle.show();
        Truck truck = new Truck(12,4000,2,8888);
        vehicle=truck;
        vehicle.show();

    }
}


class Vehicle{
    public int wheel;//轮子
    public double whight;//汽车重量

    public Vehicle(int wheel, double whight) {
        this.wheel = wheel;
        this.whight = whight;
    }
    //输出最高重量
    public void show(){
        System.out.println("轮子:"+wheel+"\n汽车重量:"+whight);
    }
}

class Car extends Vehicle{
    public int mol;//载人数量

    public Car(int wheel, double whight, int mol) {
        super(wheel, whight);
        this.mol = mol;
    }
    @Override
    public void show() {
        super.show();
        System.out.println("载人数量:"+mol);
    }
}

class Truck extends Car{
    public double maxwhigt;//最高载重

    public Truck(int wheel, double whight, int mol, double maxwhigt) {
        super(wheel, whight, mol);
        this.maxwhigt = maxwhigt;
    }
    @Override
    public void show() {
        super.show();
        System.out.println("最高载重:"+maxwhigt);
    }
}